package stringtest;

/**
 * @Author: fxy
 * @Date: 2022/02/21/14:16
 * @Description:
 *
 * 在jdk1.8中String底层使用char[]
 * 在jdk1.8以后String底层使用byte[]
 */
public class StringExer {
    public String s1 = new String("good");
    char[] ch = {'t','e','s','t'};

    public  void change(String str,char ch[]){
        System.out.println(System.identityHashCode(str)+"   "+str);
        str = "test ok";
        System.out.println(System.identityHashCode(str)+"   "+str);
        ch[0] = 'b';
    }
    public static void main(String[] args) {
        StringExer ex = new StringExer();
        System.out.println(System.identityHashCode(ex.s1)+"   "+ex.s1);

        ex.s1 = "123";
        System.out.println(System.identityHashCode(ex.s1)+"   "+ex.s1);

        ex.change(ex.s1,ex.ch);
        System.out.println(System.identityHashCode(ex.s1)+"   "+ex.s1);
        System.out.println(ex.ch);
    }
}
